package com.absurdzoo.sweetpotato;

import java.util.Random;
import java.util.Scanner;

public class game {
    public static void main(String[] args) {
        int a = 0;//玩家
        int b = 0;//ai(电脑)
        Scanner sc = new Scanner(System.in);
        System.out.println("石头剪刀布游戏启动");
        System.out.println("1:剪刀 2：石头 3：布");
        for (int i = 0; i <= 5; i++) {
            System.out.println("第"+i+"局");
            int user = Integer.parseInt(sc.next());
            int ai = new Random().nextInt(2)+1;
            System.out.println("你出的是：");
            String choose = sc.next();
            if (choose.equals("剪刀")) {
                if ( user== 1) {
                    System.out.println("你出的是:剪刀");
                    if(ai==1){
                        System.out.println("电脑出的是:剪刀");
                        System.out.println("平局");
                    }
                }
                    if(ai==2)
                        System.out.println("电脑出的是：石头");
                    System.out.println("你输了");
                    b++;
                }  if (ai == 3) {
                    System.out.println("电脑出的是布");
                    System.out.println("你赢了！！！");
                    a++;
                }  if (user==2) {
                System.out.println("你出的是：石头");
                    if (ai == 1) {
                        System.out.println("电脑出的是剪刀");
                        System.out.println("你赢了！!");
                        a++;
                    } else if (ai == 2) {
                        System.out.println("电脑出的是石头");
                        System.out.println("平局");
                    }  if (ai == 3) {
                        System.out.println("电脑出的是布");
                        System.out.println("你输了");
                        b++;
                    } else if (user==3) {
                    System.out.println("你出的是布");
                        if (ai == 1) {
                            System.out.println("电脑出的是剪刀");
                            System.out.println("你输了");
                            b++;
                        } else if (ai == 2) {
                            System.out.println("电脑出的是石头");
                            System.out.println("你赢了");
                            a++;
                        } else if (ai== 3) {
                            System.out.println("他出的是布");
                            System.out.println("平局！");
                        }
                        else {
                            System.out.println("输入错误！");
                        }
                    }
                if ( a + b == 0 ){
                    System.out.println("平局");
                }

                if (a > b){
                    System.out.println("恭喜你赢了！");
                }
                if (a < b){
                    System.out.println("你输了，ai赢");
                }
                    }
                }
            }
        }


